﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebService.Admin
{
    public partial class Languages : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ListView1_Sorting(object sender, ListViewSortEventArgs e)
        {

        }

        protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "Insert")
            {
                TextBox txtLanguage = (TextBox)e.Item.FindControl("txtLanguage");
                TextBox txtLangName = (TextBox)e.Item.FindControl("txtLangName");
                string insertCommand = "Insert into [tbl_Languages] ([Language],[LangName]) Values(N'" + txtLanguage.Text + "',N'" + txtLangName.Text + "');";
                SqlDataSource1.InsertCommand = insertCommand;
            }
            else if (e.CommandName == "Update")
            {
                TextBox txtLanguage = (TextBox)e.Item.FindControl("txtUpLanguage");
                TextBox txtLangName = (TextBox)e.Item.FindControl("txtUpLangName");
                string updateCommand = "Update [tbl_Languages] set [LangName]=N'" + txtLangName.Text + "' where [Language]='" + txtLanguage.Text + "';";
                SqlDataSource1.UpdateCommand = updateCommand;
            }
            else if (e.CommandName == "Delete")
            {
                TextBox txtLanguage = (TextBox)e.Item.FindControl("txtUpLanguage");
                string deleteCommand = "delete from [tbl_languages] where [Language]='" + txtLanguage.Text+"'";
                SqlDataSource1.DeleteCommand = deleteCommand;
            }
        }
    }
}